import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_xyf/utils/navigator_util.dart';

import 'dynamic_model.dart';
import 'second_page.dart';

class FirstPage extends StatelessWidget {
  final int count;
  final Function changeCount;
  const FirstPage(this.count, this.changeCount, {Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ElevatedButton(
            onPressed: () {
              NavigatorUtil.pushPage(
                  context: context, targetPage: ProviderDemoSecond());
              // context.rea  d<DynamicModel>().increment();
            },
            child: Text('跳转第二个页面')),
        ElevatedButton(
            onPressed: () {
              changeCount();
              // context.read<DynamicModel>().increment();
            },
            child: Text('修改count')),
        Text(

            /// Calls `context.watch` to make [Count] rebuild when [Counter] changes.
            '${this.count}',
            key: const Key('counterState'),
            style: Theme.of(context).textTheme.headline4)
      ],
    );
  }
}
